import {defineStore, acceptHMRUpdate} from "pinia";

export const useGlobalStore = defineStore({
    id: 'GlobalStore',
    state: () => ({
        apiHost: '/api',
        apiPort: '',
    }),
    getters: {
        apiServer: (state) => state.apiHost
        //+ ":" + state.apiPort
    },
    actions: {
        getImageUrl(name) {
            return new URL(name, import.meta.url).href
        },
        getapiServer() {
            return state.apiHost
        }
    }
})

// 确保传递正确的 store 声明
if (import.meta.hot) {
    import.meta.hot.accept(acceptHMRUpdate(useGlobalStore, import.meta.hot))
}